<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>分类新增</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
				<div class="layui-form-item">
				    <label class="layui-form-label">名称</label>
				    <div class="layui-input-block">
				        <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入账户" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">sequence</label>
				    <div class="layui-input-block">
				        <input type="text" name="sequence" lay-verify="sequence" autocomplete="off" placeholder="请输入账户" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">higherId</label>
				    <div class="layui-input-block">
				        <input type="text" name="higherId" lay-verify="higherId" autocomplete="off" placeholder="请输入账户" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">状态</label>
				    <div class="layui-input-block">
						<input type="checkbox" name="enable" lay-skin="switch" lay-text="ON|OFF" checked>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">备注</label>
				    <div class="layui-input-block">
				        <textarea type="text"  name="remark" lay-verify="remark" autocomplete="off" placeholder="请输入标题" class="layui-input layui-textarea"></textarea>
				    </div>
				</div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="dict-type-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form','jquery','context','permission','popup'],function(){
    let form = layui.form;
    let $ = layui.jquery;
	let context = layui.context;
	let popup = layui.popup;
	
	let basePath = context.get("base-path");
	
    form.on('submit(dict-type-save)', function(data){
		if(data.field.enable=="no"){
			data.field.enable = true;
		}else{
			data.field.enable = false;
		}
        $.ajax({
            url: basePath+'/api/sysdata/add',
            data: JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.succeeded){
                    popup.success("保存成功",function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("dict-type-table");
                    });
                }else{
                    popup.failure(result.errors);
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>